#ifndef _JMSFK_
#define _JMSFK_
#include "HardwareInfo.c"
#include <SetLCDRectangle.h>
#include <SetLCDString.h>
#include <SetLCD3Char.h>
#include <SetInBeep.h>
#include <SetCentiS.h>
#include <SetAllServo.h>
#include <SetOneServo.h>

extern  select;
 extern oldselect;


extern int a[10];

extern int touch_x,touch_y;

int JMSFK(int S1, int S2, int S3, int S4, int S5, int S6, int S7, int S8)
{
    
    
    int S[8]={S1,S2,S3,S4,S5,S6,S7,S8};
    //int a[8]={2,1,7,4,6,8,5,3};
    int Point[8][4]={
                            {20,88,90,158},
                            {100,88,170,158},
                            {200,88,270,158},
                            {85,5,155,75},
                            {5,5,75,75},
                            {200,5,270,75},
                            {5,170,75,240},
                            {85,170,155,240},
                          };
    
    //SetLCDRectangle(PointJiaJian[0][0], PointJiaJian[0][1],PointJiaJian[0][2],PointJiaJian[0][3], 1, YELLOW);
    //SetLCDRectangle(PointJiaJian[1][0], PointJiaJian[1][1],PointJiaJian[1][2],PointJiaJian[1][3], 1, YELLOW);
    if ( touch_x>0&&touch_y>0 )
    {
        
        
        
        
        if(touch_x>=Point[4][0]&&touch_x<=Point[4][2]&&touch_y>=Point[4][1]&&touch_y<=Point[4][3])
        {
        if(select!=4)
        oldselect=select;
        select=4;
        
            SetInBeep(1);
            SetCentiS(10);
            SetInBeep(0);
        }
        
        
        if(touch_x>=Point[6][0]&&touch_x<=Point[6][2]&&touch_y>=Point[6][1]&&touch_y<=Point[6][3])
        {
        if(select!=6)
        oldselect=select;
        select=6;
        
            SetInBeep(1);
            SetCentiS(10);
            SetInBeep(0);
        }
        
        
        
            
    }
    
    long fk=123;   
    
       
       if(select==8)
       {
    
          //SetLCD3Char(Point[0][0]+3, Point[0][1]+23, S[0], YELLOW, BLACK);  
    	 // SetLCD3Char(Point[1][0]+3, Point[1][1]+23, S[1], YELLOW, BLACK); 
    	//  SetLCD3Char(Point[2][0]+3, Point[2][1]+23, S[2], YELLOW, BLACK);
    	//   SetLCD3Char(Point[3][0]+3, Point[3][1]+23, S[3], YELLOW, BLACK);
    	  SetLCD3Char(Point[4][0]+3, Point[4][1]+23, S[4], YELLOW, BLACK);
    	  // SetLCD3Char(Point[5][0]+3, Point[5][1]+23, S[5], YELLOW, BLACK);
    	  SetLCD3Char(Point[6][0]+3, Point[6][1]+23, S[6], YELLOW, BLACK);
    	 //   SetLCD3Char(Point[7][0]+3, Point[7][1]+23, S[7], YELLOW, BLACK);
    	     
    	    
    	//        SetLCD3Char(Point[0][0]+3, Point[0][1]+3, a[0], RED, BLACK);
    	//      SetLCD3Char(Point[1][0]+3, Point[1][1]+3, a[1], RED, BLACK);
    	//      SetLCD3Char(Point[2][0]+3, Point[2][1]+3, a[2], RED, BLACK);
    	//      SetLCD3Char(Point[3][0]+3, Point[3][1]+3, a[3], RED, BLACK);
    	      SetLCD3Char(Point[4][0]+3, Point[4][1]+3, a[4], RED, BLACK);
    	  //     SetLCD3Char(Point[5][0]+3, Point[5][1]+3, a[5], RED, BLACK);
    	          SetLCD3Char(Point[6][0]+3, Point[6][1]+3, a[6], RED, BLACK);
    	  //    SetLCD3Char(Point[7][0]+3, Point[7][1]+3, a[7], RED, BLACK);
    	       
    	      
    	      
    	     //SetLCDString(Point[0][0]+16, Point[0][1]+2, "S", RED, BLACK);
    	    // SetLCDString(Point[1][0]+16, Point[1][1]+2, "S", RED, BLACK);
    	   //  SetLCDString(Point[2][0]+16, Point[2][1]+2, "S", RED, BLACK);
    	    //  SetLCDString(Point[3][0]+16, Point[3][1]+2, "S", RED, BLACK);
    	       SetLCDString(Point[4][0]+16, Point[4][1]+2, "S", RED, BLACK);
    	   // SetLCDString(Point[5][0]+16, Point[5][1]+2, "S6 ", RED, BLACK);
    	     SetLCDString(Point[6][0]+16, Point[6][1]+2, "S", RED, BLACK);
    	   //  SetLCDString(Point[7][0]+16, Point[7][1]+2, "S", RED, BLACK);
    	     
    	      //   SetLCDRectangle(Point[0][0], Point[0][1], Point[0][2], Point[0][3], 3, fk);
    
     //SetLCDRectangle(Point[1][0], Point[1][1], Point[1][2], Point[1][3], 3, fk);
        
    
       
    
    	     select=4;
    	     oldselect=6;
       }
       
    
    
    SetLCDRectangle(Point[select][0], Point[select][1], Point[select][2], Point[select][3], 3, GREEN);
    SetLCDRectangle(Point[oldselect][0], Point[oldselect][1], Point[oldselect][2], Point[oldselect][3], 3, fk);
    SetLCD3Char(Point[select][0]+3, Point[select][1]+23, S[select], YELLOW, BLACK);
    
    SetOneServo(_SERVOCTRL_ST_, a[select], S[select], 0);
        
        
    
    return select;
}
#endif

